SPB Git forge

spb/ai-atlas

Public
41commits 1branches 0releases
4.6 MBsize
maindefault branch
12 days agolast push
HTML 77.2% TypeScript 10.5% Python 9.6% JavaScript 2.5%
1.4 KB · 27 lines tsx
Raw Blame History
1import { ImageResponse } from 'next/og';2import { Fallback, Wallpaper } from '@/components/brand/og';3import { apiD1, safe } from '@/lib/api';4import { fmtInt } from '@/lib/format';5import { SITE_NAME } from '@/lib/site';67export const runtime = 'nodejs';8export const alt = `Licence on ${SITE_NAME}`;9export const size = { width: 1200, height: 630 };10export const contentType = 'image/png';1112const tri = (v: boolean | null) => (v === true ? 'Yes' : v === false ? 'No' : 'Unknown');1314export default async function LicenseOgImage({ params }: { params: Promise<{ key: string }> }) {15  const { key } = await params;16  const l = await safe(apiD1.license(key, 1));17  if (!l) return new ImageResponse(<Fallback label="Licence" />, { ...size });18  const counters: [string, string][] = [19    ['Commercial use', tri(l.commercial_use)],20    ['Redistribution', tri(l.redistribution)],21    ['Derivatives', tri(l.derivatives)],22    ['Models', fmtInt(l.models?.total ?? 0)],23  ];24  const subtitle = [l.category, l.spdx ? `SPDX ${l.spdx}` : null, l.osi_approved ? 'OSI approved' : null, l.weights_downloadable ? 'weights downloadable' : 'weights not downloadable'].filter(Boolean).join(' · ');25  return new ImageResponse(<Wallpaper eyebrow={`Licence · ${l.category}`} title={l.label} subtitle={subtitle} counters={counters} footer={`www.ai-atlas.co/licenses/${encodeURIComponent(l.key)}`} markPx={220} />, { ...size });26}27